package carmensd.vista

import applicationModel.OrdenDeArrestoAppModel
import org.uqbar.arena.widgets.Panel
import org.uqbar.arena.layout.ColumnLayout
import org.uqbar.arena.widgets.Label
import org.uqbar.arena.widgets.Selector
import org.uqbar.arena.bindings.PropertyAdapter
import modelo.Villano
import org.uqbar.arena.widgets.Button
import org.uqbar.arena.windows.SimpleWindow
import org.uqbar.arena.windows.WindowOwner

class OrdenDeArrestoWindow extends SimpleWindow<OrdenDeArrestoAppModel>{
	
	new(WindowOwner parent, OrdenDeArrestoAppModel model) {
		super(parent, model)
	}
	
	override protected addActions(Panel actionsPanel) {}
	
	override protected createFormPanel(Panel mainPanel) {
		this.title = "Resolviendo: " + this.getModelObject.caso.nombreCaso
		mainPanel.setLayout(new ColumnLayout(2))
		
		new Label(mainPanel).setText("orden de arresto emitida contra ")
		new Label(mainPanel).bindValueToProperty("villanoAArrestar")
		
		new Label(mainPanel).setText("villano: ")
		new Selector(mainPanel) => [
			var binding = bindItemsToProperty("expediente.villanos")
            binding.setAdapter(new PropertyAdapter(typeof(Villano), "nombre"))
			//bindItemsToProperty("expediente.villanos")
			bindValueToProperty("villanoSeleccionado")
		]
		
		new Button(mainPanel) =>[
			caption = "Generar orden de arresto"
			onClick[|this.close()]
		]
	}
}